package startup;

import java.io.*;

import javax.swing.JOptionPane;

public class IOHelper {
	
	public static void writeFile(String filename, Object content) {	
		File file = new File(filename);
		
		try {	
			FileOutputStream fos = new FileOutputStream(file);
			ObjectOutputStream oos = new ObjectOutputStream(fos);
			
			oos.writeObject(content);
			
			oos.close();
			fos.close();
		} catch (FileNotFoundException fnfe) {
			try {
				file.createNewFile();
			} catch (IOException e) {
				
			}
			writeFile(filename, content);
		} catch (IOException ie) {
			
		}
		
	}
	
	public static Object readFile(String filename){
		Object o = null;
		
		try {
			FileInputStream fis = new FileInputStream(filename);
			ObjectInputStream ois = new ObjectInputStream(fis);
			o = ois.readObject();
			ois.close();
			fis.close();
			
		} catch (Exception e) {
			
		}
		
		return o;
	}
}
